
Import('env')

progName = 'dae2ogre'


srcDir = 'src/'

variantDir = env['objDir']  + env['configurationBaseName'] + env['xmlParserConfName'] + env['validationConfName'] + '/'
outputDir =  env['binDir']  + env['configurationBaseName'] + env['xmlParserConfName'] + env['validationConfName'] + '/'
targetPath = outputDir + progName

incDirs = [ 'include',
            '../COLLADABaseUtils/include',
            '../COLLADAFramework/include',
            '../COLLADASaxFrameworkLoader/include',
            '../GeneratedSaxParser/include']

src = [ variantDir + str(p) for p in  Glob(srcDir + '*.cpp')]   
VariantDir(variant_dir=variantDir + srcDir, src_dir=srcDir, duplicate=False)

libs = [ 'OpenCOLLADASaxFrameworkLoader',
         'MathMLSolver',
         'OpenCOLLADAFramework',
         'OpenCOLLADABaseUtils',
         'GeneratedSaxParser',
         'pcre',
         'ftoa',
         'buffer',
         'UTF' ]

libPath = [ '../COLLADABaseUtils/' + env['libDir']  + env['configurationBaseName'],
            '../common/libftoa/' + env['libDir']  + env['configurationBaseName'],
            '../common/libBuffer/' + env['libDir']  + env['configurationBaseName'],
            '../COLLADAFramework/' + env['libDir']  + env['configurationBaseName'],
            '../Externals/MathMLSolver/' + env['libDir']  + env['configurationBaseName'],
            '../Externals/UTF/' + env['libDir']  + env['configurationBaseName'],
            '../COLLADASaxFrameworkLoader/' + env['libDir']  + env['configurationBaseName'] + env['xmlParserConfName'] + env['validationConfName'],
            '../GeneratedSaxParser/' + env['libDir']  + env['configurationBaseName'] + env['xmlParserConfName'] ]

if not env['PCRENATIVE']:
    libPath += '../Externals/pcre/' + env['libDir']  + env['configurationBaseName'],

else:
    libPath += '/usr/' + env['libDir']

if (env['XMLPARSER'] == 'expat') or (env['XMLPARSER'] == 'expatnative'):
    env['CPPFLAGS'] += ' -DXMLPARSER_EXPAT'
    libs += ['expat']
    if env['XMLPARSER'] == 'expat':
        libPath += ['../Externals/expat/' + env['libDir']  + env['configurationBaseName']]
else:
    env['CPPFLAGS'] += ' -DXMLPARSER_LIBXML'
    if env['XMLPARSER'] == 'libxml':
        libPath += ['../Externals/libxml/' + env['libDir']  + env['configurationBaseName']]
        libs += ['xml']
    else:
        libs += ['xml2']
        if not env['PCRENATIVE']:
            libPath += '/usr/' + env['libDir']

linkFlags = []


if env['PG']:
  linkFlags += ['-pg']

# This is commented out to allow linking against shared system libraries regardless of whether we build static or shared libs
#if not env['SHAREDLIB']:
#  linkFlags += ['-static']


Program(target=targetPath, source=src, CPPPATH=incDirs, CCFLAGS=env['CPPFLAGS'], LIBS=libs, LIBPATH=libPath, LINKFLAGS=linkFlags)

